import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PartnersVO, PartnersForm, PartnersQuery } from '@/api/logic/partners/types';

/**
 * 查询合伙人列表
 * @param query
 * @returns {*}
 */

export const listPartners = (query?: PartnersQuery): AxiosPromise<PartnersVO[]> => {
  return request({
    url: '/logic/partners/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询合伙人详细
 * @param partnerId
 */
export const getPartners = (partnerId: string | number): AxiosPromise<PartnersVO> => {
  return request({
    url: '/logic/partners/' + partnerId,
    method: 'get'
  });
};

/**
 * 新增合伙人
 * @param data
 */
export const addPartners = (data: PartnersForm) => {
  return request({
    url: '/logic/partners',
    method: 'post',
    data: data
  });
};

/**
 * 修改合伙人
 * @param data
 */
export const updatePartners = (data: PartnersForm) => {
  return request({
    url: '/logic/partners',
    method: 'put',
    data: data
  });
};

/**
 * 删除合伙人
 * @param partnerId
 */
export const delPartners = (partnerId: string | number | Array<string | number>) => {
  return request({
    url: '/logic/partners/' + partnerId,
    method: 'delete'
  });
};
